﻿using System;
using System.Collections.Generic;
using System.Globalization;

namespace AlibabaCloud.Framwork
{
    /// <summary>
    /// 阿里云 API请求 Request
    /// </summary>
    public class Request
    {
        public string HttpMethod { get; private set; }
        public string CanonicalUri { get; private set; }
        public string Protocol { get; private set; }
        public string Host { get; private set; }
        public string XAcsAction { get; private set; }
        public string XAcsVersion { get; private set; }
        public SortedDictionary<string, object> Headers { get; private set; }
        public byte[] Body { get; set; }
        public Dictionary<string, object> QueryParam { get; set; }

        public Request(string httpMethod, string canonicalUri, string protocol, string host, string xAcsAction, string xAcsVersion)
        {
            HttpMethod = httpMethod;
            CanonicalUri = canonicalUri;
            Protocol = protocol;
            Host = host;
            XAcsAction = xAcsAction;
            XAcsVersion = xAcsVersion;

            SortedDictionary<string, object> header = new SortedDictionary<string, object>();
            header.Add("host", host);
            header.Add("x-acs-action", xAcsAction);
            header.Add("x-acs-version", xAcsVersion);
            DateTime utcNow = DateTime.UtcNow;
            header.Add("x-acs-date", utcNow.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'", CultureInfo.InvariantCulture));
            header.Add("x-acs-signature-nonce", Guid.NewGuid().ToString());
            Headers = header;
            QueryParam = null;
            Body = null;
        }
    }
}
